package com.dragon;

import com.riversoft.weixin.mp.base.AppSetting;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class AppSettingFactory {

    @Value("${wechat.appid}")
    private String appid;

    @Value("${wechat.appsecret}")
    private String appSecret;

    @Value("${wechat.token:}")
    private String token;

    @Value("${wechat.tokenHolderClass:com.riversoft.weixin.common.DefaultAccessTokenHolder}")
    private String tokenHolderClass;

    private AppSetting appSetting;

    @PostConstruct
    public void init(){
        appSetting=new AppSetting();
        appSetting.setAppId(this.appid);
        appSetting.setSecret(this.appSecret);
        appSetting.setToken(this.token);
        appSetting.setTokenHolderClass(this.tokenHolderClass);
    }

    public AppSetting getAppSetting(){
        return appSetting;
    }

}
